# Maintainer:
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_name=wheezy.template
pkgname=python-wheezy-template
pkgver=3.1.0
pkgrel=5
pkgdesc="lightweight template library"
arch=(loong64 x86_64)
url="https://github.com/akornatskyy/wheezy.template"
license=(MIT)
depends=(python)
makedepends=(
  cython
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
# NOTE: no tests in pypi sdist tarball
# source=(https://files.pythonhosted.org/packages/source/${_name:0:1}/$_name/$_name-$pkgver.tar.gz)
source=(
  $pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz
  $pkgname-3.1.0-python3.11.patch  # https://github.com/akornatskyy/wheezy.template/issues/68
)
sha256sums=('a75692c8bc4aeb750a378192fe094f6c28901526c6ca754fa92f3783cdd7abcd'
            '4a77d24ec88623fac9729b5f3d4eeade8e6bbb0c14710ff229844dd4d7c3e26a')
b2sums=('6cbaa6e5656a0b3bf417ed500770c97f2207f97822ccdf624c87cb0f3c0d2fa3b1a2269641325c6d6138568aeff3bcc417e6e4896186e2fe7c1b31a15e2d7365'
        '2d38b102c63459e1561b2864b954cce1c706f5163b43d2f860f09a33d99cf50ce2729303eb91da04238484595502b1a85ef39d114b695fc27d6261502804b3bb')

prepare() {
  patch -Np1 -d $_name-$pkgver -i ../$pkgname-3.1.0-python3.11.patch
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="$PWD/src:$PYTHONPATH"
  pytest --import-mode=importlib
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
